<?php

namespace App\Http\Controllers\Admin;

use Illuminate\Http\Request;
use App\Http\Controllers\Controller;
use App\Models\Notice;

class NoticeController extends Controller
{
    public function index(Request $request)
    {
        $where = [];              
        $list = Notice::where($where)->paginate(20);
        return view('admin.notice.index',compact('list','where'));

    }

    public function edit(Request $request,$id)
    {
    	
    	$data = Notice::find($id);
    	return view('admin.notice.edit',compact('data'));

    }

    public function create(Request $request)
    {
        return view('admin.notice.add');

    }

    public function update(Request $request)
    {
    	$id = $request->id;
    	$data = $request->except(['_token','id','_method']);
    	Notice::where(['id'=>$id])->update($data);
    	return back();
    }

     public function store(Request $request)
    {
        $id = $request->id;
        $data = $request->except(['_token']);
        Notice::create($data);
        return redirect('zadmin/notice/');
    }


    public function destroy($id)
    {
        Notice::destroy($id);
        return back();
    }
}
